// hook函数
// 1. 对组件功能的抽取
import { getMedicalOrderDetail } from "@/apis/order"
import type { MedicalOrderDetail } from "@/types/room"
import { ref } from "vue"

// 2.命名是以useXXX
export const useMedic = (orderId:string) => { 
    const orderDetail = ref<MedicalOrderDetail>({} as MedicalOrderDetail)
    const getOrderDetail = async () => {
      if (orderId === '') {
        uni.showToast({
          title: '订单出现了问题',
          icon: 'none',
        })
        uni.switchTab({ url: '/pages/my/index' })
      }
      const res = await getMedicalOrderDetail(orderId)
      orderDetail.value = res
      console.log(orderDetail.value)
    }
    getOrderDetail()
    return {orderDetail}
}
